{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "ad89b779-fdc8-480c-b0c4-eda530fae955",
   "metadata": {},
   "source": [
    "### Try this notebook in Google Colab, Binder or SageMaker!\n",
    "\n",
    "[![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/InsightSoftwareConsortium/itkwidgets/blob/main/examples/integrations/xarray/DataArray.ipynb)\n",
    "[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/InsightSoftwareConsortium/itkwidgets/HEAD?labpath=examples%2Fintegrations%2Fxarray%2FDataArray.ipynb)\n",
    "[![Open In SageMaker Studio Lab](https://studiolab.sagemaker.aws/studiolab.svg)](https://studiolab.sagemaker.aws/import/github.com/InsightSoftwareConsortium/itkwidgets/blob/main/examples/integrations/xarray/DataArray.ipynb)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "58a7abea-7bd5-4668-82a2-70f79d9a6a25",
   "metadata": {},
   "outputs": [],
   "source": [
    "import sys\n",
    "\n",
    "!{sys.executable} -m pip install -q netCDF4 xarray pooch \"itkwidgets[all]>=1.0a23\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "d99ecd85-f3ed-4f50-ac7c-f0b8d327d79f",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import xarray as xr\n",
    "from itkwidgets import view"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "55897e16-ad3f-4633-aad9-6aa4dee8e5ce",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><svg style=\"position: absolute; width: 0; height: 0; overflow: hidden\">\n",
       "<defs>\n",
       "<symbol id=\"icon-database\" viewBox=\"0 0 32 32\">\n",
       "<path d=\"M16 0c-8.837 0-16 2.239-16 5v4c0 2.761 7.163 5 16 5s16-2.239 16-5v-4c0-2.761-7.163-5-16-5z\"></path>\n",
       "<path d=\"M16 17c-8.837 0-16-2.239-16-5v6c0 2.761 7.163 5 16 5s16-2.239 16-5v-6c0 2.761-7.163 5-16 5z\"></path>\n",
       "<path d=\"M16 26c-8.837 0-16-2.239-16-5v6c0 2.761 7.163 5 16 5s16-2.239 16-5v-6c0 2.761-7.163 5-16 5z\"></path>\n",
       "</symbol>\n",
       "<symbol id=\"icon-file-text2\" viewBox=\"0 0 32 32\">\n",
       "<path d=\"M28.681 7.159c-0.694-0.947-1.662-2.053-2.724-3.116s-2.169-2.030-3.116-2.724c-1.612-1.182-2.393-1.319-2.841-1.319h-15.5c-1.378 0-2.5 1.121-2.5 2.5v27c0 1.378 1.122 2.5 2.5 2.5h23c1.378 0 2.5-1.122 2.5-2.5v-19.5c0-0.448-0.137-1.23-1.319-2.841zM24.543 5.457c0.959 0.959 1.712 1.825 2.268 2.543h-4.811v-4.811c0.718 0.556 1.584 1.309 2.543 2.268zM28 29.5c0 0.271-0.229 0.5-0.5 0.5h-23c-0.271 0-0.5-0.229-0.5-0.5v-27c0-0.271 0.229-0.5 0.5-0.5 0 0 15.499-0 15.5 0v7c0 0.552 0.448 1 1 1h7v19.5z\"></path>\n",
       "<path d=\"M23 26h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
       "<path d=\"M23 22h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
       "<path d=\"M23 18h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
       "</symbol>\n",
       "</defs>\n",
       "</svg>\n",
       "<style>/* CSS stylesheet for displaying xarray objects in jupyterlab.\n",
       " *\n",
       " */\n",
       "\n",
       ":root {\n",
       "  --xr-font-color0: var(--jp-content-font-color0, rgba(0, 0, 0, 1));\n",
       "  --xr-font-color2: var(--jp-content-font-color2, rgba(0, 0, 0, 0.54));\n",
       "  --xr-font-color3: var(--jp-content-font-color3, rgba(0, 0, 0, 0.38));\n",
       "  --xr-border-color: var(--jp-border-color2, #e0e0e0);\n",
       "  --xr-disabled-color: var(--jp-layout-color3, #bdbdbd);\n",
       "  --xr-background-color: var(--jp-layout-color0, white);\n",
       "  --xr-background-color-row-even: var(--jp-layout-color1, white);\n",
       "  --xr-background-color-row-odd: var(--jp-layout-color2, #eeeeee);\n",
       "}\n",
       "\n",
       "html[theme=dark],\n",
       "body[data-theme=dark],\n",
       "body.vscode-dark {\n",
       "  --xr-font-color0: rgba(255, 255, 255, 1);\n",
       "  --xr-font-color2: rgba(255, 255, 255, 0.54);\n",
       "  --xr-font-color3: rgba(255, 255, 255, 0.38);\n",
       "  --xr-border-color: #1F1F1F;\n",
       "  --xr-disabled-color: #515151;\n",
       "  --xr-background-color: #111111;\n",
       "  --xr-background-color-row-even: #111111;\n",
       "  --xr-background-color-row-odd: #313131;\n",
       "}\n",
       "\n",
       ".xr-wrap {\n",
       "  display: block !important;\n",
       "  min-width: 300px;\n",
       "  max-width: 700px;\n",
       "}\n",
       "\n",
       ".xr-text-repr-fallback {\n",
       "  /* fallback to plain text repr when CSS is not injected (untrusted notebook) */\n",
       "  display: none;\n",
       "}\n",
       "\n",
       ".xr-header {\n",
       "  padding-top: 6px;\n",
       "  padding-bottom: 6px;\n",
       "  margin-bottom: 4px;\n",
       "  border-bottom: solid 1px var(--xr-border-color);\n",
       "}\n",
       "\n",
       ".xr-header > div,\n",
       ".xr-header > ul {\n",
       "  display: inline;\n",
       "  margin-top: 0;\n",
       "  margin-bottom: 0;\n",
       "}\n",
       "\n",
       ".xr-obj-type,\n",
       ".xr-array-name {\n",
       "  margin-left: 2px;\n",
       "  margin-right: 10px;\n",
       "}\n",
       "\n",
       ".xr-obj-type {\n",
       "  color: var(--xr-font-color2);\n",
       "}\n",
       "\n",
       ".xr-sections {\n",
       "  padding-left: 0 !important;\n",
       "  display: grid;\n",
       "  grid-template-columns: 150px auto auto 1fr 20px 20px;\n",
       "}\n",
       "\n",
       ".xr-section-item {\n",
       "  display: contents;\n",
       "}\n",
       "\n",
       ".xr-section-item input {\n",
       "  display: none;\n",
       "}\n",
       "\n",
       ".xr-section-item input + label {\n",
       "  color: var(--xr-disabled-color);\n",
       "}\n",
       "\n",
       ".xr-section-item input:enabled + label {\n",
       "  cursor: pointer;\n",
       "  color: var(--xr-font-color2);\n",
       "}\n",
       "\n",
       ".xr-section-item input:enabled + label:hover {\n",
       "  color: var(--xr-font-color0);\n",
       "}\n",
       "\n",
       ".xr-section-summary {\n",
       "  grid-column: 1;\n",
       "  color: var(--xr-font-color2);\n",
       "  font-weight: 500;\n",
       "}\n",
       "\n",
       ".xr-section-summary > span {\n",
       "  display: inline-block;\n",
       "  padding-left: 0.5em;\n",
       "}\n",
       "\n",
       ".xr-section-summary-in:disabled + label {\n",
       "  color: var(--xr-font-color2);\n",
       "}\n",
       "\n",
       ".xr-section-summary-in + label:before {\n",
       "  display: inline-block;\n",
       "  content: '►';\n",
       "  font-size: 11px;\n",
       "  width: 15px;\n",
       "  text-align: center;\n",
       "}\n",
       "\n",
       ".xr-section-summary-in:disabled + label:before {\n",
       "  color: var(--xr-disabled-color);\n",
       "}\n",
       "\n",
       ".xr-section-summary-in:checked + label:before {\n",
       "  content: '▼';\n",
       "}\n",
       "\n",
       ".xr-section-summary-in:checked + label > span {\n",
       "  display: none;\n",
       "}\n",
       "\n",
       ".xr-section-summary,\n",
       ".xr-section-inline-details {\n",
       "  padding-top: 4px;\n",
       "  padding-bottom: 4px;\n",
       "}\n",
       "\n",
       ".xr-section-inline-details {\n",
       "  grid-column: 2 / -1;\n",
       "}\n",
       "\n",
       ".xr-section-details {\n",
       "  display: none;\n",
       "  grid-column: 1 / -1;\n",
       "  margin-bottom: 5px;\n",
       "}\n",
       "\n",
       ".xr-section-summary-in:checked ~ .xr-section-details {\n",
       "  display: contents;\n",
       "}\n",
       "\n",
       ".xr-array-wrap {\n",
       "  grid-column: 1 / -1;\n",
       "  display: grid;\n",
       "  grid-template-columns: 20px auto;\n",
       "}\n",
       "\n",
       ".xr-array-wrap > label {\n",
       "  grid-column: 1;\n",
       "  vertical-align: top;\n",
       "}\n",
       "\n",
       ".xr-preview {\n",
       "  color: var(--xr-font-color3);\n",
       "}\n",
       "\n",
       ".xr-array-preview,\n",
       ".xr-array-data {\n",
       "  padding: 0 5px !important;\n",
       "  grid-column: 2;\n",
       "}\n",
       "\n",
       ".xr-array-data,\n",
       ".xr-array-in:checked ~ .xr-array-preview {\n",
       "  display: none;\n",
       "}\n",
       "\n",
       ".xr-array-in:checked ~ .xr-array-data,\n",
       ".xr-array-preview {\n",
       "  display: inline-block;\n",
       "}\n",
       "\n",
       ".xr-dim-list {\n",
       "  display: inline-block !important;\n",
       "  list-style: none;\n",
       "  padding: 0 !important;\n",
       "  margin: 0;\n",
       "}\n",
       "\n",
       ".xr-dim-list li {\n",
       "  display: inline-block;\n",
       "  padding: 0;\n",
       "  margin: 0;\n",
       "}\n",
       "\n",
       ".xr-dim-list:before {\n",
       "  content: '(';\n",
       "}\n",
       "\n",
       ".xr-dim-list:after {\n",
       "  content: ')';\n",
       "}\n",
       "\n",
       ".xr-dim-list li:not(:last-child):after {\n",
       "  content: ',';\n",
       "  padding-right: 5px;\n",
       "}\n",
       "\n",
       ".xr-has-index {\n",
       "  font-weight: bold;\n",
       "}\n",
       "\n",
       ".xr-var-list,\n",
       ".xr-var-item {\n",
       "  display: contents;\n",
       "}\n",
       "\n",
       ".xr-var-item > div,\n",
       ".xr-var-item label,\n",
       ".xr-var-item > .xr-var-name span {\n",
       "  background-color: var(--xr-background-color-row-even);\n",
       "  margin-bottom: 0;\n",
       "}\n",
       "\n",
       ".xr-var-item > .xr-var-name:hover span {\n",
       "  padding-right: 5px;\n",
       "}\n",
       "\n",
       ".xr-var-list > li:nth-child(odd) > div,\n",
       ".xr-var-list > li:nth-child(odd) > label,\n",
       ".xr-var-list > li:nth-child(odd) > .xr-var-name span {\n",
       "  background-color: var(--xr-background-color-row-odd);\n",
       "}\n",
       "\n",
       ".xr-var-name {\n",
       "  grid-column: 1;\n",
       "}\n",
       "\n",
       ".xr-var-dims {\n",
       "  grid-column: 2;\n",
       "}\n",
       "\n",
       ".xr-var-dtype {\n",
       "  grid-column: 3;\n",
       "  text-align: right;\n",
       "  color: var(--xr-font-color2);\n",
       "}\n",
       "\n",
       ".xr-var-preview {\n",
       "  grid-column: 4;\n",
       "}\n",
       "\n",
       ".xr-var-name,\n",
       ".xr-var-dims,\n",
       ".xr-var-dtype,\n",
       ".xr-preview,\n",
       ".xr-attrs dt {\n",
       "  white-space: nowrap;\n",
       "  overflow: hidden;\n",
       "  text-overflow: ellipsis;\n",
       "  padding-right: 10px;\n",
       "}\n",
       "\n",
       ".xr-var-name:hover,\n",
       ".xr-var-dims:hover,\n",
       ".xr-var-dtype:hover,\n",
       ".xr-attrs dt:hover {\n",
       "  overflow: visible;\n",
       "  width: auto;\n",
       "  z-index: 1;\n",
       "}\n",
       "\n",
       ".xr-var-attrs,\n",
       ".xr-var-data {\n",
       "  display: none;\n",
       "  background-color: var(--xr-background-color) !important;\n",
       "  padding-bottom: 5px !important;\n",
       "}\n",
       "\n",
       ".xr-var-attrs-in:checked ~ .xr-var-attrs,\n",
       ".xr-var-data-in:checked ~ .xr-var-data {\n",
       "  display: block;\n",
       "}\n",
       "\n",
       ".xr-var-data > table {\n",
       "  float: right;\n",
       "}\n",
       "\n",
       ".xr-var-name span,\n",
       ".xr-var-data,\n",
       ".xr-attrs {\n",
       "  padding-left: 25px !important;\n",
       "}\n",
       "\n",
       ".xr-attrs,\n",
       ".xr-var-attrs,\n",
       ".xr-var-data {\n",
       "  grid-column: 1 / -1;\n",
       "}\n",
       "\n",
       "dl.xr-attrs {\n",
       "  padding: 0;\n",
       "  margin: 0;\n",
       "  display: grid;\n",
       "  grid-template-columns: 125px auto;\n",
       "}\n",
       "\n",
       ".xr-attrs dt,\n",
       ".xr-attrs dd {\n",
       "  padding: 0;\n",
       "  margin: 0;\n",
       "  float: left;\n",
       "  padding-right: 10px;\n",
       "  width: auto;\n",
       "}\n",
       "\n",
       ".xr-attrs dt {\n",
       "  font-weight: normal;\n",
       "  grid-column: 1;\n",
       "}\n",
       "\n",
       ".xr-attrs dt:hover span {\n",
       "  display: inline-block;\n",
       "  background: var(--xr-background-color);\n",
       "  padding-right: 10px;\n",
       "}\n",
       "\n",
       ".xr-attrs dd {\n",
       "  grid-column: 2;\n",
       "  white-space: pre-wrap;\n",
       "  word-break: break-all;\n",
       "}\n",
       "\n",
       ".xr-icon-database,\n",
       ".xr-icon-file-text2 {\n",
       "  display: inline-block;\n",
       "  vertical-align: middle;\n",
       "  width: 1em;\n",
       "  height: 1.5em !important;\n",
       "  stroke-width: 0;\n",
       "  stroke: currentColor;\n",
       "  fill: currentColor;\n",
       "}\n",
       "</style><pre class='xr-text-repr-fallback'>&lt;xarray.Dataset&gt;\n",
       "Dimensions:     (ocean_time: 2, s_rho: 30, eta_rho: 191, xi_rho: 371)\n",
       "Coordinates:\n",
       "    Cs_r        (s_rho) float64 -0.933 -0.8092 -0.6988 ... -0.0005206 -5.758e-05\n",
       "    lon_rho     (eta_rho, xi_rho) float64 -93.6 -93.58 -93.57 ... -88.88 -88.87\n",
       "    hc          float64 20.0\n",
       "    h           (eta_rho, xi_rho) float64 612.1 610.9 609.7 ... 5.0 5.0 5.0\n",
       "    lat_rho     (eta_rho, xi_rho) float64 27.45 27.45 27.45 ... 30.85 30.86\n",
       "    Vtransform  int32 2\n",
       "  * ocean_time  (ocean_time) datetime64[ns] 2001-08-01 2001-08-08\n",
       "  * s_rho       (s_rho) float64 -0.9833 -0.95 -0.9167 ... -0.05 -0.01667\n",
       "Dimensions without coordinates: eta_rho, xi_rho\n",
       "Data variables:\n",
       "    salt        (ocean_time, s_rho, eta_rho, xi_rho) float32 ...\n",
       "    zeta        (ocean_time, eta_rho, xi_rho) float32 ...\n",
       "Attributes: (12/34)\n",
       "    file:              ../output_20yr_obc/2001/ocean_his_0015.nc\n",
       "    format:            netCDF-4/HDF5 file\n",
       "    Conventions:       CF-1.4\n",
       "    type:              ROMS/TOMS history file\n",
       "    title:             TXLA ROMS hindcast run with dyes and oxygen\n",
       "    rst_file:          ../output_20yr_obc/2001/ocean_rst.nc\n",
       "    ...                ...\n",
       "    compiler_flags:    -heap-arrays -fp-model fast -mt_mpi -ip -O3 -msse2 -free\n",
       "    tiling:            010x012\n",
       "    history:           Tue Jul 24 11:04:43 2018: /opt/nco/ncks -D 4 -t 8 /cop...\n",
       "    ana_file:          /home/d.kobashi/TXLA_ROMS_reana/Functionals/ana_btflux...\n",
       "    CPP_options:       TXLA2, ANA_BPFLUX, ANA_BSFLUX, ANA_BTFLUX, ANA_NUDGCOE...\n",
       "    NCO:               netCDF Operators version 4.7.6-alpha04 (Homepage = htt...</pre><div class='xr-wrap' style='display:none'><div class='xr-header'><div class='xr-obj-type'>xarray.Dataset</div></div><ul class='xr-sections'><li class='xr-section-item'><input id='section-847b5fbd-ca50-47d2-b988-6718d39a80a8' class='xr-section-summary-in' type='checkbox' disabled ><label for='section-847b5fbd-ca50-47d2-b988-6718d39a80a8' class='xr-section-summary'  title='Expand/collapse section'>Dimensions:</label><div class='xr-section-inline-details'><ul class='xr-dim-list'><li><span class='xr-has-index'>ocean_time</span>: 2</li><li><span class='xr-has-index'>s_rho</span>: 30</li><li><span>eta_rho</span>: 191</li><li><span>xi_rho</span>: 371</li></ul></div><div class='xr-section-details'></div></li><li class='xr-section-item'><input id='section-708b7911-7c87-4026-ae9d-96c9cc7b95f1' class='xr-section-summary-in' type='checkbox'  checked><label for='section-708b7911-7c87-4026-ae9d-96c9cc7b95f1' class='xr-section-summary' >Coordinates: <span>(8)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'><li class='xr-var-item'><div class='xr-var-name'><span>Cs_r</span></div><div class='xr-var-dims'>(s_rho)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>...</div><input id='attrs-005cda97-ce19-49eb-8984-87dba1d9e511' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-005cda97-ce19-49eb-8984-87dba1d9e511' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-a7c6dad9-bf8b-4d99-8633-bc32f00ece37' class='xr-var-data-in' type='checkbox'><label for='data-a7c6dad9-bf8b-4d99-8633-bc32f00ece37' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'><dt><span>long_name :</span></dt><dd>S-coordinate stretching curves at RHO-points</dd><dt><span>valid_min :</span></dt><dd>-1.0</dd><dt><span>valid_max :</span></dt><dd>0.0</dd><dt><span>field :</span></dt><dd>Cs_r, scalar</dd></dl></div><div class='xr-var-data'><pre>array([-9.330104e-01, -8.092347e-01, -6.987799e-01, -6.010089e-01,\n",
       "       -5.150586e-01, -4.399389e-01, -3.746092e-01, -3.180318e-01,\n",
       "       -2.692093e-01, -2.272075e-01, -1.911684e-01, -1.603161e-01,\n",
       "       -1.339573e-01, -1.114783e-01, -9.234047e-02, -7.607411e-02,\n",
       "       -6.227187e-02, -5.058234e-02, -4.070376e-02, -3.237816e-02,\n",
       "       -2.538600e-02, -1.954143e-02, -1.468804e-02, -1.069526e-02,\n",
       "       -7.455152e-03, -4.879814e-03, -2.899170e-03, -1.459199e-03,\n",
       "       -5.205601e-04, -5.757740e-05])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>lon_rho</span></div><div class='xr-var-dims'>(eta_rho, xi_rho)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>...</div><input id='attrs-44f943b2-7315-4bd4-bd03-43ea6c6f7165' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-44f943b2-7315-4bd4-bd03-43ea6c6f7165' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-19e13240-f055-4bb0-981c-4f397e8588a9' class='xr-var-data-in' type='checkbox'><label for='data-19e13240-f055-4bb0-981c-4f397e8588a9' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'><dt><span>long_name :</span></dt><dd>longitude of RHO-points</dd><dt><span>units :</span></dt><dd>degree_east</dd><dt><span>standard_name :</span></dt><dd>longitude</dd><dt><span>field :</span></dt><dd>lon_rho, scalar</dd></dl></div><div class='xr-var-data'><pre>array([[-93.599115, -93.584318, -93.569454, ..., -87.763032, -87.751866,\n",
       "        -87.741496],\n",
       "       [-93.600866, -93.586068, -93.571203, ..., -87.768848, -87.757124,\n",
       "        -87.745656],\n",
       "       [-93.602749, -93.587941, -93.573068, ..., -87.774371, -87.762102,\n",
       "        -87.749894],\n",
       "       ...,\n",
       "       [-94.289859, -94.263083, -94.236598, ..., -88.878928, -88.865315,\n",
       "        -88.852469],\n",
       "       [-94.294293, -94.267315, -94.240694, ..., -88.88544 , -88.871751,\n",
       "        -88.858994],\n",
       "       [-94.298533, -94.271401, -94.244679, ..., -88.891837, -88.877973,\n",
       "        -88.865142]])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>hc</span></div><div class='xr-var-dims'>()</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>...</div><input id='attrs-e9c6c205-5511-4e16-9673-f5118f53f476' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-e9c6c205-5511-4e16-9673-f5118f53f476' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-85b7dc62-490b-455d-908c-d61b3a0a44f3' class='xr-var-data-in' type='checkbox'><label for='data-85b7dc62-490b-455d-908c-d61b3a0a44f3' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'><dt><span>long_name :</span></dt><dd>S-coordinate parameter, critical depth</dd><dt><span>units :</span></dt><dd>meter</dd></dl></div><div class='xr-var-data'><pre>array(20.)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>h</span></div><div class='xr-var-dims'>(eta_rho, xi_rho)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>...</div><input id='attrs-f0dee5a7-39fe-4f06-a848-09128ffadd01' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-f0dee5a7-39fe-4f06-a848-09128ffadd01' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-16184c56-1915-47ba-9a21-4b8fa1d11146' class='xr-var-data-in' type='checkbox'><label for='data-16184c56-1915-47ba-9a21-4b8fa1d11146' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'><dt><span>long_name :</span></dt><dd>bathymetry at RHO-points</dd><dt><span>units :</span></dt><dd>meter</dd><dt><span>field :</span></dt><dd>bath, scalar</dd></dl></div><div class='xr-var-data'><pre>array([[612.131311, 610.900759, 609.666854, ..., 652.491881, 636.527055,\n",
       "        625.32749 ],\n",
       "       [605.404475, 603.86427 , 602.58879 , ..., 598.344434, 581.330959,\n",
       "        573.818742],\n",
       "       [599.015111, 596.869247, 595.552341, ..., 542.83258 , 525.375498,\n",
       "        517.881682],\n",
       "       ...,\n",
       "       [  5.      ,   5.      ,   5.      , ...,   5.      ,   5.      ,\n",
       "          5.      ],\n",
       "       [  5.      ,   5.      ,   5.      , ...,   5.      ,   5.      ,\n",
       "          5.      ],\n",
       "       [  5.      ,   5.      ,   5.      , ...,   5.      ,   5.      ,\n",
       "          5.      ]])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>lat_rho</span></div><div class='xr-var-dims'>(eta_rho, xi_rho)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>...</div><input id='attrs-1b104373-af9a-47da-b94c-eeef9e396b1b' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-1b104373-af9a-47da-b94c-eeef9e396b1b' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-65af024e-8bef-4ee9-9c19-d28fdc6b58e3' class='xr-var-data-in' type='checkbox'><label for='data-65af024e-8bef-4ee9-9c19-d28fdc6b58e3' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'><dt><span>long_name :</span></dt><dd>latitude of RHO-points</dd><dt><span>units :</span></dt><dd>degree_north</dd><dt><span>standard_name :</span></dt><dd>latitude</dd><dt><span>field :</span></dt><dd>lat_rho, scalar</dd></dl></div><div class='xr-var-data'><pre>array([[27.447302, 27.448518, 27.449734, ..., 29.221501, 29.227283, 29.23234 ],\n",
       "       [27.463363, 27.464679, 27.465989, ..., 29.230354, 29.235771, 29.24048 ],\n",
       "       [27.479345, 27.480759, 27.482163, ..., 29.239503, 29.244737, 29.2494  ],\n",
       "       ...,\n",
       "       [29.89585 , 29.900997, 29.905927, ..., 30.827387, 30.83811 , 30.848897],\n",
       "       [29.913254, 29.918199, 29.922963, ..., 30.833696, 30.8441  , 30.854414],\n",
       "       [29.93092 , 29.935606, 29.940175, ..., 30.840105, 30.850178, 30.859782]])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>Vtransform</span></div><div class='xr-var-dims'>()</div><div class='xr-var-dtype'>int32</div><div class='xr-var-preview xr-preview'>...</div><input id='attrs-198bd426-c87f-44cb-9aeb-fdf1173cf84d' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-198bd426-c87f-44cb-9aeb-fdf1173cf84d' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-698f7243-89b8-4aac-8716-14d04a34da91' class='xr-var-data-in' type='checkbox'><label for='data-698f7243-89b8-4aac-8716-14d04a34da91' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'><dt><span>long_name :</span></dt><dd>vertical terrain-following transformation equation</dd></dl></div><div class='xr-var-data'><pre>array(2, dtype=int32)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>ocean_time</span></div><div class='xr-var-dims'>(ocean_time)</div><div class='xr-var-dtype'>datetime64[ns]</div><div class='xr-var-preview xr-preview'>2001-08-01 2001-08-08</div><input id='attrs-f8e6a6f3-0001-41a4-ad92-58510e2aa72d' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-f8e6a6f3-0001-41a4-ad92-58510e2aa72d' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-fecc8935-673b-4daf-9854-a85e9b99ce93' class='xr-var-data-in' type='checkbox'><label for='data-fecc8935-673b-4daf-9854-a85e9b99ce93' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'><dt><span>long_name :</span></dt><dd>time since initialization</dd><dt><span>field :</span></dt><dd>time, scalar, series</dd></dl></div><div class='xr-var-data'><pre>array([&#x27;2001-08-01T00:00:00.000000000&#x27;, &#x27;2001-08-08T00:00:00.000000000&#x27;],\n",
       "      dtype=&#x27;datetime64[ns]&#x27;)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>s_rho</span></div><div class='xr-var-dims'>(s_rho)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>-0.9833 -0.95 ... -0.05 -0.01667</div><input id='attrs-22b0fb33-ac78-4891-b957-183ba3928b8d' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-22b0fb33-ac78-4891-b957-183ba3928b8d' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-ce62e3f8-2873-48c1-8d20-a5834686a78f' class='xr-var-data-in' type='checkbox'><label for='data-ce62e3f8-2873-48c1-8d20-a5834686a78f' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'><dt><span>long_name :</span></dt><dd>S-coordinate at RHO-points</dd><dt><span>valid_min :</span></dt><dd>-1.0</dd><dt><span>valid_max :</span></dt><dd>0.0</dd><dt><span>positive :</span></dt><dd>up</dd><dt><span>standard_name :</span></dt><dd>ocean_s_coordinate_g2</dd><dt><span>formula_terms :</span></dt><dd>s: s_rho C: Cs_r eta: zeta depth: h depth_c: hc</dd><dt><span>field :</span></dt><dd>s_rho, scalar</dd></dl></div><div class='xr-var-data'><pre>array([-0.983333, -0.95    , -0.916667, -0.883333, -0.85    , -0.816667,\n",
       "       -0.783333, -0.75    , -0.716667, -0.683333, -0.65    , -0.616667,\n",
       "       -0.583333, -0.55    , -0.516667, -0.483333, -0.45    , -0.416667,\n",
       "       -0.383333, -0.35    , -0.316667, -0.283333, -0.25    , -0.216667,\n",
       "       -0.183333, -0.15    , -0.116667, -0.083333, -0.05    , -0.016667])</pre></div></li></ul></div></li><li class='xr-section-item'><input id='section-a6dbd9ce-1949-473b-a99c-07a9f504513b' class='xr-section-summary-in' type='checkbox'  checked><label for='section-a6dbd9ce-1949-473b-a99c-07a9f504513b' class='xr-section-summary' >Data variables: <span>(2)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'><li class='xr-var-item'><div class='xr-var-name'><span>salt</span></div><div class='xr-var-dims'>(ocean_time, s_rho, eta_rho, xi_rho)</div><div class='xr-var-dtype'>float32</div><div class='xr-var-preview xr-preview'>...</div><input id='attrs-47db1d58-f7af-4080-9a0b-71f7ffc3ab80' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-47db1d58-f7af-4080-9a0b-71f7ffc3ab80' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-1444ff49-cdd7-42ca-b38f-44736d9e9998' class='xr-var-data-in' type='checkbox'><label for='data-1444ff49-cdd7-42ca-b38f-44736d9e9998' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'><dt><span>long_name :</span></dt><dd>salinity</dd><dt><span>time :</span></dt><dd>ocean_time</dd><dt><span>field :</span></dt><dd>salinity, scalar, series</dd></dl></div><div class='xr-var-data'><pre>[4251660 values with dtype=float32]</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>zeta</span></div><div class='xr-var-dims'>(ocean_time, eta_rho, xi_rho)</div><div class='xr-var-dtype'>float32</div><div class='xr-var-preview xr-preview'>...</div><input id='attrs-126654cf-b47c-490c-98c1-25edf393e96f' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-126654cf-b47c-490c-98c1-25edf393e96f' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-eea8e7d8-f7df-4325-87df-a238a0d8faad' class='xr-var-data-in' type='checkbox'><label for='data-eea8e7d8-f7df-4325-87df-a238a0d8faad' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'><dt><span>long_name :</span></dt><dd>free-surface</dd><dt><span>units :</span></dt><dd>meter</dd><dt><span>time :</span></dt><dd>ocean_time</dd><dt><span>field :</span></dt><dd>free-surface, scalar, series</dd></dl></div><div class='xr-var-data'><pre>[141722 values with dtype=float32]</pre></div></li></ul></div></li><li class='xr-section-item'><input id='section-059ff2d8-6230-41c6-9fcb-4abe33fe0967' class='xr-section-summary-in' type='checkbox'  ><label for='section-059ff2d8-6230-41c6-9fcb-4abe33fe0967' class='xr-section-summary' >Attributes: <span>(34)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><dl class='xr-attrs'><dt><span>file :</span></dt><dd>../output_20yr_obc/2001/ocean_his_0015.nc</dd><dt><span>format :</span></dt><dd>netCDF-4/HDF5 file</dd><dt><span>Conventions :</span></dt><dd>CF-1.4</dd><dt><span>type :</span></dt><dd>ROMS/TOMS history file</dd><dt><span>title :</span></dt><dd>TXLA ROMS hindcast run with dyes and oxygen</dd><dt><span>rst_file :</span></dt><dd>../output_20yr_obc/2001/ocean_rst.nc</dd><dt><span>his_base :</span></dt><dd>../output_20yr_obc/2001/ocean_his</dd><dt><span>avg_base :</span></dt><dd>../output_20yr_obc/2001/ocean_avg</dd><dt><span>dia_base :</span></dt><dd>../output_20yr_obc/2001/ocean_dia</dd><dt><span>sta_file :</span></dt><dd>ocean_sta.nc</dd><dt><span>grd_file :</span></dt><dd>../inputs/grd/txla2_grd_v4_test_lcut_hglo_wtype.nc</dd><dt><span>ini_file :</span></dt><dd>../output_20yr_obc/2000/ocean_rst.nc</dd><dt><span>frc_file_01 :</span></dt><dd>../inputs/2001/txla_bulk_ERAI_2001.nc</dd><dt><span>frc_file_02 :</span></dt><dd>../inputs/2001/txla_flx_ICOADS_AVHRR_SST_2001.nc, ../inputs/2002/txla_flx_ICOADS_AVHRR_SST_2002.nc</dd><dt><span>bry_file_01 :</span></dt><dd>../inputs/2001/txla2_bry_2001_glo_ReAna_v4_o2woa.nc, ../inputs/2002/txla2_bry_2002_glo_ReAna_v4_o2woa.nc</dd><dt><span>clm_file_01 :</span></dt><dd>../inputs/2001/txla2_clm_2001_01_glo_ReAna_v4_o2woa.nc, ../inputs/2001/txla2_clm_2001_02_glo_ReAna_v4_o2woa.nc, ../inputs/2001/txla2_clm_2001_03_glo_ReAna_v4_o2woa.nc, ../inputs/2001/txla2_clm_2001_04_glo_ReAna_v4_o2woa.nc, ../inputs/2001/txla2_clm_2001_05_glo_ReAna_v4_o2woa.nc, ../inputs/2001/txla2_clm_2001_06_glo_ReAna_v4_o2woa.nc, ../inputs/2001/txla2_clm_2001_07_glo_ReAna_v4_o2woa.nc, ../inputs/2001/txla2_clm_2001_08_glo_ReAna_v4_o2woa.nc, ../inputs/2001/txla2_clm_2001_09_glo_ReAna_v4_o2woa.nc, ../inputs/2001/txla2_clm_2001_10_glo_ReAna_v4_o2woa.nc, ../inputs/2001/txla2_clm_2001_11_glo_ReAna_v4_o2woa.nc, ../inputs/2001/txla2_clm_2001_12_glo_ReAna_v4_o2woa.nc, ../inputs/2002/txla2_clm_2002_01_glo_ReAna_v4_o2woa.nc</dd><dt><span>script_file :</span></dt><dd></dd><dt><span>spos_file :</span></dt><dd>/scratch/user/d.kobashi/inputs/stations.in</dd><dt><span>NLM_LBC :</span></dt><dd>\n",
       "EDGE:    WEST   SOUTH  EAST   NORTH  \n",
       "zeta:    Che    Che    Che    Clo    \n",
       "ubar:    Shc    Shc    Shc    Clo    \n",
       "vbar:    Shc    Shc    Shc    Clo    \n",
       "u:       Rad    Rad    Rad    Clo    \n",
       "v:       Rad    Rad    Rad    Clo    \n",
       "temp:    Rad    Rad    Rad    Clo    \n",
       "salt:    Rad    Rad    Rad    Clo    \n",
       "dye_01:  Gra    Gra    Gra    Clo    \n",
       "dye_02:  Rad    Rad    Rad    Clo    \n",
       "dye_03:  Rad    Rad    Rad    Clo    \n",
       "dye_04:  Rad    Rad    Rad    Clo    \n",
       "tke:     Gra    Gra    Gra    Clo</dd><dt><span>svn_url :</span></dt><dd>https:://myroms.org/svn/src</dd><dt><span>svn_rev :</span></dt><dd></dd><dt><span>code_dir :</span></dt><dd>/scratch/user/d.kobashi/source_code/COAWST/COAWST.r960-dev</dd><dt><span>header_dir :</span></dt><dd>/home/d.kobashi/TXLA_ROMS_reana/work_20yr_obc</dd><dt><span>header_file :</span></dt><dd>txla2.h</dd><dt><span>os :</span></dt><dd>Linux</dd><dt><span>cpu :</span></dt><dd>x86_64</dd><dt><span>compiler_system :</span></dt><dd>ifort</dd><dt><span>compiler_command :</span></dt><dd>/software/easybuild/software/impi/5.0.1.035-iccifort-2015.0.090/bin64/mpiifort</dd><dt><span>compiler_flags :</span></dt><dd>-heap-arrays -fp-model fast -mt_mpi -ip -O3 -msse2 -free</dd><dt><span>tiling :</span></dt><dd>010x012</dd><dt><span>history :</span></dt><dd>Tue Jul 24 11:04:43 2018: /opt/nco/ncks -D 4 -t 8 /copano/d1/shared/TXLA_ROMS/output_20yr_obc/2001/ocean_his_0015.nc --cnk_dmn ocean_time,4 --cnk_dmn eta_rho,8 --cnk_dmn eta_u,8 --cnk_dmn eta_v,8 --cnk_dmn eta_psi,8 --cnk_dmn xi_rho,16 --cnk_dmn xi_u,16 --cnk_dmn xi_v,16 --cnk_dmn xi_psi,16 --cnk_dmn s_rho,2 --cnk_dmn s_w,2 --output /copano/d2/shared/TXLA_ROMS/output_20yr_obc/2001/ocean_his_0015.nc\n",
       "ROMS/TOMS, Version 3.7, Monday - July 18, 2016 - 10:38:26 PM</dd><dt><span>ana_file :</span></dt><dd>/home/d.kobashi/TXLA_ROMS_reana/Functionals/ana_btflux.h, /home/d.kobashi/TXLA_ROMS_reana/Functionals/ana_sponge.h, /home/d.kobashi/TXLA_ROMS_reana/Functionals/ana_nudgcoef.h, /home/d.kobashi/TXLA_ROMS_reana/Functionals/ana_stflux.h</dd><dt><span>CPP_options :</span></dt><dd>TXLA2, ANA_BPFLUX, ANA_BSFLUX, ANA_BTFLUX, ANA_NUDGCOEF, ANA_SPFLUX, ANA_SPONGE, ASSUMED_SHAPE, AVERAGES, BULK_FLUXES, CURVGRID, DEFLATE, DIAGNOSTICS_TS, DIAGNOSTICS_UV, DIFF_GRID, DJ_GRADPS, DOUBLE_PRECISION, EMINUSP, GLS_MIXING, HDF5, KANTHA_CLAYSON, LONGWAVE, MASKING, MIX_GEO_TS, MIX_S_UV, MPI, NONLINEAR, NONLIN_EOS, N2S2_HORAVG, POWER_LAW, PROFILE, QCORRECTION, K_GSCHEME, RADIATION_2D, !RST_SINGLE, SALINITY, SOLAR_SOURCE, SOLVE3D, SPLINES, SPHERICAL, STATIONS, T_PASSIVE, TS_MPDATA, TS_DIF2, UV_ADV, UV_COR, UV_U3HADVECTION, UV_C4VADVECTION, UV_LOGDRAG, UV_VIS2, VAR_RHO_2D, VISC_GRID, WTYPE_GRID</dd><dt><span>NCO :</span></dt><dd>netCDF Operators version 4.7.6-alpha04 (Homepage = http://nco.sf.net, Code = http://github.com/nco/nco)</dd></dl></div></li></ul></div></div>"
      ],
      "text/plain": [
       "<xarray.Dataset>\n",
       "Dimensions:     (ocean_time: 2, s_rho: 30, eta_rho: 191, xi_rho: 371)\n",
       "Coordinates:\n",
       "    Cs_r        (s_rho) float64 ...\n",
       "    lon_rho     (eta_rho, xi_rho) float64 ...\n",
       "    hc          float64 ...\n",
       "    h           (eta_rho, xi_rho) float64 ...\n",
       "    lat_rho     (eta_rho, xi_rho) float64 ...\n",
       "    Vtransform  int32 ...\n",
       "  * ocean_time  (ocean_time) datetime64[ns] 2001-08-01 2001-08-08\n",
       "  * s_rho       (s_rho) float64 -0.9833 -0.95 -0.9167 ... -0.05 -0.01667\n",
       "Dimensions without coordinates: eta_rho, xi_rho\n",
       "Data variables:\n",
       "    salt        (ocean_time, s_rho, eta_rho, xi_rho) float32 ...\n",
       "    zeta        (ocean_time, eta_rho, xi_rho) float32 ...\n",
       "Attributes: (12/34)\n",
       "    file:              ../output_20yr_obc/2001/ocean_his_0015.nc\n",
       "    format:            netCDF-4/HDF5 file\n",
       "    Conventions:       CF-1.4\n",
       "    type:              ROMS/TOMS history file\n",
       "    title:             TXLA ROMS hindcast run with dyes and oxygen\n",
       "    rst_file:          ../output_20yr_obc/2001/ocean_rst.nc\n",
       "    ...                ...\n",
       "    compiler_flags:    -heap-arrays -fp-model fast -mt_mpi -ip -O3 -msse2 -free\n",
       "    tiling:            010x012\n",
       "    history:           Tue Jul 24 11:04:43 2018: /opt/nco/ncks -D 4 -t 8 /cop...\n",
       "    ana_file:          /home/d.kobashi/TXLA_ROMS_reana/Functionals/ana_btflux...\n",
       "    CPP_options:       TXLA2, ANA_BPFLUX, ANA_BSFLUX, ANA_BTFLUX, ANA_NUDGCOE...\n",
       "    NCO:               netCDF Operators version 4.7.6-alpha04 (Homepage = htt..."
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# load in the file\n",
    "ds = xr.tutorial.open_dataset(\"ROMS_example\")\n",
    "\n",
    "# This is a way to turn on chunking and lazy evaluation. Opening with mfdataset, or\n",
    "# setting the chunking in the open_dataset would also achieve this.\n",
    "ds"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "763b592c-18c2-4631-aeee-68e5e5649b70",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "                <img id=screenshot_imjoy_window_36929f2b-0b72-42a1-8eee-3aac596bfb62 src=>\n",
       "                <script id=\"script_imjoy_window_36929f2b-0b72-42a1-8eee-3aac596bfb62\" type=\"text/javascript\">\n",
       "                    var container = document.getElementById(\"script_imjoy_window_36929f2b-0b72-42a1-8eee-3aac596bfb62\").parentNode;\n",
       "                    var image = document.getElementById(\"screenshot_imjoy_window_36929f2b-0b72-42a1-8eee-3aac596bfb62\");\n",
       "                    if (!image) {\n",
       "                        image = document.createElement(\"img\");\n",
       "                        image.id = \"screenshot_imjoy_window_36929f2b-0b72-42a1-8eee-3aac596bfb62\";\n",
       "                        container.appendChild(image);\n",
       "                    }\n",
       "                    image.src = \"\";\n",
       "                    var viewer = document.getElementById(\"imjoy_window_36929f2b-0b72-42a1-8eee-3aac596bfb62\");\n",
       "                    // Hide the static image if the Viewer is visible\n",
       "                    image.style.display = viewer ? \"none\" : \"block\";\n",
       "                </script>\n",
       "            "
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/javascript": [
       "window.connectPlugin && window.connectPlugin(\"fb48e912-9af8-4f29-8be7-0c810a80524b\")"
      ],
      "text/plain": [
       "<IPython.core.display.Javascript object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div id=\"54abddae-5a05-48df-92e5-9bd7c2e30691\"></div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "<itkwidgets.viewer.Viewer at 0x7f364721d9a0>"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "view(ds.zeta, ui_collapsed=False, cmap=\"Asymmtrical Earth Tones (6_21b)\", sample_distance=0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "a8e4938c-e769-4f8e-97de-42dbb39caa1e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><svg style=\"position: absolute; width: 0; height: 0; overflow: hidden\">\n",
       "<defs>\n",
       "<symbol id=\"icon-database\" viewBox=\"0 0 32 32\">\n",
       "<path d=\"M16 0c-8.837 0-16 2.239-16 5v4c0 2.761 7.163 5 16 5s16-2.239 16-5v-4c0-2.761-7.163-5-16-5z\"></path>\n",
       "<path d=\"M16 17c-8.837 0-16-2.239-16-5v6c0 2.761 7.163 5 16 5s16-2.239 16-5v-6c0 2.761-7.163 5-16 5z\"></path>\n",
       "<path d=\"M16 26c-8.837 0-16-2.239-16-5v6c0 2.761 7.163 5 16 5s16-2.239 16-5v-6c0 2.761-7.163 5-16 5z\"></path>\n",
       "</symbol>\n",
       "<symbol id=\"icon-file-text2\" viewBox=\"0 0 32 32\">\n",
       "<path d=\"M28.681 7.159c-0.694-0.947-1.662-2.053-2.724-3.116s-2.169-2.030-3.116-2.724c-1.612-1.182-2.393-1.319-2.841-1.319h-15.5c-1.378 0-2.5 1.121-2.5 2.5v27c0 1.378 1.122 2.5 2.5 2.5h23c1.378 0 2.5-1.122 2.5-2.5v-19.5c0-0.448-0.137-1.23-1.319-2.841zM24.543 5.457c0.959 0.959 1.712 1.825 2.268 2.543h-4.811v-4.811c0.718 0.556 1.584 1.309 2.543 2.268zM28 29.5c0 0.271-0.229 0.5-0.5 0.5h-23c-0.271 0-0.5-0.229-0.5-0.5v-27c0-0.271 0.229-0.5 0.5-0.5 0 0 15.499-0 15.5 0v7c0 0.552 0.448 1 1 1h7v19.5z\"></path>\n",
       "<path d=\"M23 26h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
       "<path d=\"M23 22h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
       "<path d=\"M23 18h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
       "</symbol>\n",
       "</defs>\n",
       "</svg>\n",
       "<style>/* CSS stylesheet for displaying xarray objects in jupyterlab.\n",
       " *\n",
       " */\n",
       "\n",
       ":root {\n",
       "  --xr-font-color0: var(--jp-content-font-color0, rgba(0, 0, 0, 1));\n",
       "  --xr-font-color2: var(--jp-content-font-color2, rgba(0, 0, 0, 0.54));\n",
       "  --xr-font-color3: var(--jp-content-font-color3, rgba(0, 0, 0, 0.38));\n",
       "  --xr-border-color: var(--jp-border-color2, #e0e0e0);\n",
       "  --xr-disabled-color: var(--jp-layout-color3, #bdbdbd);\n",
       "  --xr-background-color: var(--jp-layout-color0, white);\n",
       "  --xr-background-color-row-even: var(--jp-layout-color1, white);\n",
       "  --xr-background-color-row-odd: var(--jp-layout-color2, #eeeeee);\n",
       "}\n",
       "\n",
       "html[theme=dark],\n",
       "body[data-theme=dark],\n",
       "body.vscode-dark {\n",
       "  --xr-font-color0: rgba(255, 255, 255, 1);\n",
       "  --xr-font-color2: rgba(255, 255, 255, 0.54);\n",
       "  --xr-font-color3: rgba(255, 255, 255, 0.38);\n",
       "  --xr-border-color: #1F1F1F;\n",
       "  --xr-disabled-color: #515151;\n",
       "  --xr-background-color: #111111;\n",
       "  --xr-background-color-row-even: #111111;\n",
       "  --xr-background-color-row-odd: #313131;\n",
       "}\n",
       "\n",
       ".xr-wrap {\n",
       "  display: block !important;\n",
       "  min-width: 300px;\n",
       "  max-width: 700px;\n",
       "}\n",
       "\n",
       ".xr-text-repr-fallback {\n",
       "  /* fallback to plain text repr when CSS is not injected (untrusted notebook) */\n",
       "  display: none;\n",
       "}\n",
       "\n",
       ".xr-header {\n",
       "  padding-top: 6px;\n",
       "  padding-bottom: 6px;\n",
       "  margin-bottom: 4px;\n",
       "  border-bottom: solid 1px var(--xr-border-color);\n",
       "}\n",
       "\n",
       ".xr-header > div,\n",
       ".xr-header > ul {\n",
       "  display: inline;\n",
       "  margin-top: 0;\n",
       "  margin-bottom: 0;\n",
       "}\n",
       "\n",
       ".xr-obj-type,\n",
       ".xr-array-name {\n",
       "  margin-left: 2px;\n",
       "  margin-right: 10px;\n",
       "}\n",
       "\n",
       ".xr-obj-type {\n",
       "  color: var(--xr-font-color2);\n",
       "}\n",
       "\n",
       ".xr-sections {\n",
       "  padding-left: 0 !important;\n",
       "  display: grid;\n",
       "  grid-template-columns: 150px auto auto 1fr 20px 20px;\n",
       "}\n",
       "\n",
       ".xr-section-item {\n",
       "  display: contents;\n",
       "}\n",
       "\n",
       ".xr-section-item input {\n",
       "  display: none;\n",
       "}\n",
       "\n",
       ".xr-section-item input + label {\n",
       "  color: var(--xr-disabled-color);\n",
       "}\n",
       "\n",
       ".xr-section-item input:enabled + label {\n",
       "  cursor: pointer;\n",
       "  color: var(--xr-font-color2);\n",
       "}\n",
       "\n",
       ".xr-section-item input:enabled + label:hover {\n",
       "  color: var(--xr-font-color0);\n",
       "}\n",
       "\n",
       ".xr-section-summary {\n",
       "  grid-column: 1;\n",
       "  color: var(--xr-font-color2);\n",
       "  font-weight: 500;\n",
       "}\n",
       "\n",
       ".xr-section-summary > span {\n",
       "  display: inline-block;\n",
       "  padding-left: 0.5em;\n",
       "}\n",
       "\n",
       ".xr-section-summary-in:disabled + label {\n",
       "  color: var(--xr-font-color2);\n",
       "}\n",
       "\n",
       ".xr-section-summary-in + label:before {\n",
       "  display: inline-block;\n",
       "  content: '►';\n",
       "  font-size: 11px;\n",
       "  width: 15px;\n",
       "  text-align: center;\n",
       "}\n",
       "\n",
       ".xr-section-summary-in:disabled + label:before {\n",
       "  color: var(--xr-disabled-color);\n",
       "}\n",
       "\n",
       ".xr-section-summary-in:checked + label:before {\n",
       "  content: '▼';\n",
       "}\n",
       "\n",
       ".xr-section-summary-in:checked + label > span {\n",
       "  display: none;\n",
       "}\n",
       "\n",
       ".xr-section-summary,\n",
       ".xr-section-inline-details {\n",
       "  padding-top: 4px;\n",
       "  padding-bottom: 4px;\n",
       "}\n",
       "\n",
       ".xr-section-inline-details {\n",
       "  grid-column: 2 / -1;\n",
       "}\n",
       "\n",
       ".xr-section-details {\n",
       "  display: none;\n",
       "  grid-column: 1 / -1;\n",
       "  margin-bottom: 5px;\n",
       "}\n",
       "\n",
       ".xr-section-summary-in:checked ~ .xr-section-details {\n",
       "  display: contents;\n",
       "}\n",
       "\n",
       ".xr-array-wrap {\n",
       "  grid-column: 1 / -1;\n",
       "  display: grid;\n",
       "  grid-template-columns: 20px auto;\n",
       "}\n",
       "\n",
       ".xr-array-wrap > label {\n",
       "  grid-column: 1;\n",
       "  vertical-align: top;\n",
       "}\n",
       "\n",
       ".xr-preview {\n",
       "  color: var(--xr-font-color3);\n",
       "}\n",
       "\n",
       ".xr-array-preview,\n",
       ".xr-array-data {\n",
       "  padding: 0 5px !important;\n",
       "  grid-column: 2;\n",
       "}\n",
       "\n",
       ".xr-array-data,\n",
       ".xr-array-in:checked ~ .xr-array-preview {\n",
       "  display: none;\n",
       "}\n",
       "\n",
       ".xr-array-in:checked ~ .xr-array-data,\n",
       ".xr-array-preview {\n",
       "  display: inline-block;\n",
       "}\n",
       "\n",
       ".xr-dim-list {\n",
       "  display: inline-block !important;\n",
       "  list-style: none;\n",
       "  padding: 0 !important;\n",
       "  margin: 0;\n",
       "}\n",
       "\n",
       ".xr-dim-list li {\n",
       "  display: inline-block;\n",
       "  padding: 0;\n",
       "  margin: 0;\n",
       "}\n",
       "\n",
       ".xr-dim-list:before {\n",
       "  content: '(';\n",
       "}\n",
       "\n",
       ".xr-dim-list:after {\n",
       "  content: ')';\n",
       "}\n",
       "\n",
       ".xr-dim-list li:not(:last-child):after {\n",
       "  content: ',';\n",
       "  padding-right: 5px;\n",
       "}\n",
       "\n",
       ".xr-has-index {\n",
       "  font-weight: bold;\n",
       "}\n",
       "\n",
       ".xr-var-list,\n",
       ".xr-var-item {\n",
       "  display: contents;\n",
       "}\n",
       "\n",
       ".xr-var-item > div,\n",
       ".xr-var-item label,\n",
       ".xr-var-item > .xr-var-name span {\n",
       "  background-color: var(--xr-background-color-row-even);\n",
       "  margin-bottom: 0;\n",
       "}\n",
       "\n",
       ".xr-var-item > .xr-var-name:hover span {\n",
       "  padding-right: 5px;\n",
       "}\n",
       "\n",
       ".xr-var-list > li:nth-child(odd) > div,\n",
       ".xr-var-list > li:nth-child(odd) > label,\n",
       ".xr-var-list > li:nth-child(odd) > .xr-var-name span {\n",
       "  background-color: var(--xr-background-color-row-odd);\n",
       "}\n",
       "\n",
       ".xr-var-name {\n",
       "  grid-column: 1;\n",
       "}\n",
       "\n",
       ".xr-var-dims {\n",
       "  grid-column: 2;\n",
       "}\n",
       "\n",
       ".xr-var-dtype {\n",
       "  grid-column: 3;\n",
       "  text-align: right;\n",
       "  color: var(--xr-font-color2);\n",
       "}\n",
       "\n",
       ".xr-var-preview {\n",
       "  grid-column: 4;\n",
       "}\n",
       "\n",
       ".xr-var-name,\n",
       ".xr-var-dims,\n",
       ".xr-var-dtype,\n",
       ".xr-preview,\n",
       ".xr-attrs dt {\n",
       "  white-space: nowrap;\n",
       "  overflow: hidden;\n",
       "  text-overflow: ellipsis;\n",
       "  padding-right: 10px;\n",
       "}\n",
       "\n",
       ".xr-var-name:hover,\n",
       ".xr-var-dims:hover,\n",
       ".xr-var-dtype:hover,\n",
       ".xr-attrs dt:hover {\n",
       "  overflow: visible;\n",
       "  width: auto;\n",
       "  z-index: 1;\n",
       "}\n",
       "\n",
       ".xr-var-attrs,\n",
       ".xr-var-data {\n",
       "  display: none;\n",
       "  background-color: var(--xr-background-color) !important;\n",
       "  padding-bottom: 5px !important;\n",
       "}\n",
       "\n",
       ".xr-var-attrs-in:checked ~ .xr-var-attrs,\n",
       ".xr-var-data-in:checked ~ .xr-var-data {\n",
       "  display: block;\n",
       "}\n",
       "\n",
       ".xr-var-data > table {\n",
       "  float: right;\n",
       "}\n",
       "\n",
       ".xr-var-name span,\n",
       ".xr-var-data,\n",
       ".xr-attrs {\n",
       "  padding-left: 25px !important;\n",
       "}\n",
       "\n",
       ".xr-attrs,\n",
       ".xr-var-attrs,\n",
       ".xr-var-data {\n",
       "  grid-column: 1 / -1;\n",
       "}\n",
       "\n",
       "dl.xr-attrs {\n",
       "  padding: 0;\n",
       "  margin: 0;\n",
       "  display: grid;\n",
       "  grid-template-columns: 125px auto;\n",
       "}\n",
       "\n",
       ".xr-attrs dt,\n",
       ".xr-attrs dd {\n",
       "  padding: 0;\n",
       "  margin: 0;\n",
       "  float: left;\n",
       "  padding-right: 10px;\n",
       "  width: auto;\n",
       "}\n",
       "\n",
       ".xr-attrs dt {\n",
       "  font-weight: normal;\n",
       "  grid-column: 1;\n",
       "}\n",
       "\n",
       ".xr-attrs dt:hover span {\n",
       "  display: inline-block;\n",
       "  background: var(--xr-background-color);\n",
       "  padding-right: 10px;\n",
       "}\n",
       "\n",
       ".xr-attrs dd {\n",
       "  grid-column: 2;\n",
       "  white-space: pre-wrap;\n",
       "  word-break: break-all;\n",
       "}\n",
       "\n",
       ".xr-icon-database,\n",
       ".xr-icon-file-text2 {\n",
       "  display: inline-block;\n",
       "  vertical-align: middle;\n",
       "  width: 1em;\n",
       "  height: 1.5em !important;\n",
       "  stroke-width: 0;\n",
       "  stroke: currentColor;\n",
       "  fill: currentColor;\n",
       "}\n",
       "</style><pre class='xr-text-repr-fallback'>&lt;xarray.DataArray &#x27;salt&#x27; (ocean_time: 2, s_rho: 30, eta_rho: 191, xi_rho: 371)&gt;\n",
       "[4251660 values with dtype=float32]\n",
       "Coordinates:\n",
       "    Cs_r        (s_rho) float64 -0.933 -0.8092 -0.6988 ... -0.0005206 -5.758e-05\n",
       "    lon_rho     (xi_rho, eta_rho) float64 -93.6 -93.6 -93.6 ... -88.86 -88.87\n",
       "    hc          float64 20.0\n",
       "    h           (xi_rho, eta_rho) float64 612.1 605.4 599.0 ... 5.0 5.0 5.0\n",
       "    lat_rho     (xi_rho, eta_rho) float64 27.45 27.46 27.48 ... 30.85 30.86\n",
       "    Vtransform  int32 2\n",
       "  * ocean_time  (ocean_time) datetime64[ns] 2001-08-01 2001-08-08\n",
       "  * s_rho       (s_rho) float64 -0.9833 -0.95 -0.9167 ... -0.05 -0.01667\n",
       "    z_rho       (s_rho, xi_rho, eta_rho, ocean_time) float64 -572.1 ... nan\n",
       "Dimensions without coordinates: eta_rho, xi_rho\n",
       "Attributes:\n",
       "    long_name:  salinity\n",
       "    time:       ocean_time\n",
       "    field:      salinity, scalar, series</pre><div class='xr-wrap' style='display:none'><div class='xr-header'><div class='xr-obj-type'>xarray.DataArray</div><div class='xr-array-name'>'salt'</div><ul class='xr-dim-list'><li><span class='xr-has-index'>ocean_time</span>: 2</li><li><span class='xr-has-index'>s_rho</span>: 30</li><li><span>eta_rho</span>: 191</li><li><span>xi_rho</span>: 371</li></ul></div><ul class='xr-sections'><li class='xr-section-item'><div class='xr-array-wrap'><input id='section-a3d464fb-abe0-4393-85c9-e08744c5b063' class='xr-array-in' type='checkbox' checked><label for='section-a3d464fb-abe0-4393-85c9-e08744c5b063' title='Show/hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-array-preview xr-preview'><span>...</span></div><div class='xr-array-data'><pre>[4251660 values with dtype=float32]</pre></div></div></li><li class='xr-section-item'><input id='section-80cd0092-59cf-4964-8b42-c04e576ffcbc' class='xr-section-summary-in' type='checkbox'  checked><label for='section-80cd0092-59cf-4964-8b42-c04e576ffcbc' class='xr-section-summary' >Coordinates: <span>(9)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'><li class='xr-var-item'><div class='xr-var-name'><span>Cs_r</span></div><div class='xr-var-dims'>(s_rho)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>-0.933 -0.8092 ... -5.758e-05</div><input id='attrs-f4f74b19-68ce-4c0f-9716-82696014564d' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-f4f74b19-68ce-4c0f-9716-82696014564d' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-d6e75914-2e02-4a90-a6df-fd69e44acf2e' class='xr-var-data-in' type='checkbox'><label for='data-d6e75914-2e02-4a90-a6df-fd69e44acf2e' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'><dt><span>long_name :</span></dt><dd>S-coordinate stretching curves at RHO-points</dd><dt><span>valid_min :</span></dt><dd>-1.0</dd><dt><span>valid_max :</span></dt><dd>0.0</dd><dt><span>field :</span></dt><dd>Cs_r, scalar</dd></dl></div><div class='xr-var-data'><pre>array([-9.33010396e-01, -8.09234736e-01, -6.98779853e-01, -6.01008926e-01,\n",
       "       -5.15058562e-01, -4.39938913e-01, -3.74609181e-01, -3.18031817e-01,\n",
       "       -2.69209327e-01, -2.27207488e-01, -1.91168387e-01, -1.60316097e-01,\n",
       "       -1.33957253e-01, -1.11478268e-01, -9.23404709e-02, -7.60741092e-02,\n",
       "       -6.22718662e-02, -5.05823390e-02, -4.07037635e-02, -3.23781605e-02,\n",
       "       -2.53860004e-02, -1.95414261e-02, -1.46880431e-02, -1.06952600e-02,\n",
       "       -7.45515186e-03, -4.87981407e-03, -2.89916971e-03, -1.45919898e-03,\n",
       "       -5.20560097e-04, -5.75774004e-05])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>lon_rho</span></div><div class='xr-var-dims'>(xi_rho, eta_rho)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>-93.6 -93.6 -93.6 ... -88.86 -88.87</div><input id='attrs-8640eb53-946e-4499-9aac-f087bced428b' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-8640eb53-946e-4499-9aac-f087bced428b' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-33b07b15-7c96-4d78-b2cc-79d6f1142cfa' class='xr-var-data-in' type='checkbox'><label for='data-33b07b15-7c96-4d78-b2cc-79d6f1142cfa' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'><dt><span>long_name :</span></dt><dd>longitude of RHO-points</dd><dt><span>units :</span></dt><dd>degree_east</dd><dt><span>standard_name :</span></dt><dd>longitude</dd><dt><span>field :</span></dt><dd>lon_rho, scalar</dd></dl></div><div class='xr-var-data'><pre>array([[-93.5991148 , -93.60086556, -93.60274915, ..., -94.28985864,\n",
       "        -94.29429293, -94.29853291],\n",
       "       [-93.58431806, -93.5860676 , -93.58794141, ..., -94.2630832 ,\n",
       "        -94.26731521, -94.27140073],\n",
       "       [-93.56945391, -93.57120251, -93.57306769, ..., -94.2365978 ,\n",
       "        -94.2406939 , -94.24467877],\n",
       "       ...,\n",
       "       [-87.7630322 , -87.76884797, -87.77437096, ..., -88.87892784,\n",
       "        -88.88544049, -88.89183705],\n",
       "       [-87.7518658 , -87.75712403, -87.76210198, ..., -88.86531501,\n",
       "        -88.87175123, -88.87797295],\n",
       "       [-87.74149609, -87.74565588, -87.74989378, ..., -88.85246884,\n",
       "        -88.85899415, -88.86514193]])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>hc</span></div><div class='xr-var-dims'>()</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>20.0</div><input id='attrs-24ba8ff9-5f28-4de9-b1cd-65f9e96bc19d' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-24ba8ff9-5f28-4de9-b1cd-65f9e96bc19d' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-1abcecd5-fc50-48e8-ab05-8d63574cda58' class='xr-var-data-in' type='checkbox'><label for='data-1abcecd5-fc50-48e8-ab05-8d63574cda58' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'><dt><span>long_name :</span></dt><dd>S-coordinate parameter, critical depth</dd><dt><span>units :</span></dt><dd>meter</dd></dl></div><div class='xr-var-data'><pre>array(20.)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>h</span></div><div class='xr-var-dims'>(xi_rho, eta_rho)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>612.1 605.4 599.0 ... 5.0 5.0 5.0</div><input id='attrs-ea297b7c-9333-42d4-b8cb-cfa21831f254' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-ea297b7c-9333-42d4-b8cb-cfa21831f254' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-8134ac68-32ab-4aad-98f0-b2b12e244716' class='xr-var-data-in' type='checkbox'><label for='data-8134ac68-32ab-4aad-98f0-b2b12e244716' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'><dt><span>long_name :</span></dt><dd>bathymetry at RHO-points</dd><dt><span>units :</span></dt><dd>meter</dd><dt><span>field :</span></dt><dd>bath, scalar</dd></dl></div><div class='xr-var-data'><pre>array([[612.13131089, 605.4044752 , 599.0151105 , ...,   5.        ,\n",
       "          5.        ,   5.        ],\n",
       "       [610.90075909, 603.86427029, 596.86924674, ...,   5.        ,\n",
       "          5.        ,   5.        ],\n",
       "       [609.66685361, 602.58879025, 595.55234084, ...,   5.        ,\n",
       "          5.        ,   5.        ],\n",
       "       ...,\n",
       "       [652.49188119, 598.34443354, 542.83258037, ...,   5.        ,\n",
       "          5.        ,   5.        ],\n",
       "       [636.52705503, 581.33095882, 525.37549794, ...,   5.        ,\n",
       "          5.        ,   5.        ],\n",
       "       [625.32748994, 573.81874195, 517.881682  , ...,   5.        ,\n",
       "          5.        ,   5.        ]])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>lat_rho</span></div><div class='xr-var-dims'>(xi_rho, eta_rho)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>27.45 27.46 27.48 ... 30.85 30.86</div><input id='attrs-03327f6c-dd2c-4483-889c-1008e4694647' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-03327f6c-dd2c-4483-889c-1008e4694647' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-225ea43a-0622-4b51-a7cc-5bf14b4f692e' class='xr-var-data-in' type='checkbox'><label for='data-225ea43a-0622-4b51-a7cc-5bf14b4f692e' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'><dt><span>long_name :</span></dt><dd>latitude of RHO-points</dd><dt><span>units :</span></dt><dd>degree_north</dd><dt><span>standard_name :</span></dt><dd>latitude</dd><dt><span>field :</span></dt><dd>lat_rho, scalar</dd></dl></div><div class='xr-var-data'><pre>array([[27.44730242, 27.46336319, 27.47934455, ..., 29.89585021,\n",
       "        29.91325359, 29.93092021],\n",
       "       [27.44851789, 27.46467912, 27.48075948, ..., 29.9009966 ,\n",
       "        29.91819871, 29.93560622],\n",
       "       [27.44973378, 27.4659893 , 27.48216278, ..., 29.9059268 ,\n",
       "        29.92296278, 29.94017512],\n",
       "       ...,\n",
       "       [29.22150101, 29.2303535 , 29.23950299, ..., 30.82738658,\n",
       "        30.83369624, 30.84010483],\n",
       "       [29.22728312, 29.23577132, 29.24473717, ..., 30.83811034,\n",
       "        30.84409983, 30.85017791],\n",
       "       [29.23234048, 29.24047951, 29.24939979, ..., 30.84889664,\n",
       "        30.85441368, 30.85978189]])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>Vtransform</span></div><div class='xr-var-dims'>()</div><div class='xr-var-dtype'>int32</div><div class='xr-var-preview xr-preview'>2</div><input id='attrs-166802bb-b5cd-4a4d-b7c9-8c104f9032d2' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-166802bb-b5cd-4a4d-b7c9-8c104f9032d2' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-bcf5998c-0e99-4d17-bab2-ce31e7544365' class='xr-var-data-in' type='checkbox'><label for='data-bcf5998c-0e99-4d17-bab2-ce31e7544365' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'><dt><span>long_name :</span></dt><dd>vertical terrain-following transformation equation</dd></dl></div><div class='xr-var-data'><pre>array(2, dtype=int32)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>ocean_time</span></div><div class='xr-var-dims'>(ocean_time)</div><div class='xr-var-dtype'>datetime64[ns]</div><div class='xr-var-preview xr-preview'>2001-08-01 2001-08-08</div><input id='attrs-44f29597-46e6-4673-8bb9-43ec0dde0b3e' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-44f29597-46e6-4673-8bb9-43ec0dde0b3e' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-c2917919-52a6-4ca1-ba90-9339bbfb672e' class='xr-var-data-in' type='checkbox'><label for='data-c2917919-52a6-4ca1-ba90-9339bbfb672e' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'><dt><span>long_name :</span></dt><dd>time since initialization</dd><dt><span>field :</span></dt><dd>time, scalar, series</dd></dl></div><div class='xr-var-data'><pre>array([&#x27;2001-08-01T00:00:00.000000000&#x27;, &#x27;2001-08-08T00:00:00.000000000&#x27;],\n",
       "      dtype=&#x27;datetime64[ns]&#x27;)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>s_rho</span></div><div class='xr-var-dims'>(s_rho)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>-0.9833 -0.95 ... -0.05 -0.01667</div><input id='attrs-399dba34-84bb-40fa-9f4f-e42456a36d65' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-399dba34-84bb-40fa-9f4f-e42456a36d65' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-69e36161-be6b-40ed-8caf-9f57edabe767' class='xr-var-data-in' type='checkbox'><label for='data-69e36161-be6b-40ed-8caf-9f57edabe767' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'><dt><span>long_name :</span></dt><dd>S-coordinate at RHO-points</dd><dt><span>valid_min :</span></dt><dd>-1.0</dd><dt><span>valid_max :</span></dt><dd>0.0</dd><dt><span>positive :</span></dt><dd>up</dd><dt><span>standard_name :</span></dt><dd>ocean_s_coordinate_g2</dd><dt><span>formula_terms :</span></dt><dd>s: s_rho C: Cs_r eta: zeta depth: h depth_c: hc</dd><dt><span>field :</span></dt><dd>s_rho, scalar</dd></dl></div><div class='xr-var-data'><pre>array([-0.983333, -0.95    , -0.916667, -0.883333, -0.85    , -0.816667,\n",
       "       -0.783333, -0.75    , -0.716667, -0.683333, -0.65    , -0.616667,\n",
       "       -0.583333, -0.55    , -0.516667, -0.483333, -0.45    , -0.416667,\n",
       "       -0.383333, -0.35    , -0.316667, -0.283333, -0.25    , -0.216667,\n",
       "       -0.183333, -0.15    , -0.116667, -0.083333, -0.05    , -0.016667])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>z_rho</span></div><div class='xr-var-dims'>(s_rho, xi_rho, eta_rho, ocean_time)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>-572.1 -572.1 -565.8 ... nan nan</div><input id='attrs-0d96804e-9dcf-4ee4-b7b9-f0c3507293d4' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-0d96804e-9dcf-4ee4-b7b9-f0c3507293d4' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-14c75f9e-7656-454b-9311-02e469c1586b' class='xr-var-data-in' type='checkbox'><label for='data-14c75f9e-7656-454b-9311-02e469c1586b' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([[[[-5.72109729e+02, -5.72107882e+02],\n",
       "         [-5.65833178e+02, -5.65831329e+02],\n",
       "         [-5.59871551e+02, -5.59869775e+02],\n",
       "         ...,\n",
       "         [            nan,             nan],\n",
       "         [            nan,             nan],\n",
       "         [            nan,             nan]],\n",
       "\n",
       "        [[-5.70961471e+02, -5.70959646e+02],\n",
       "         [-5.64395992e+02, -5.64394167e+02],\n",
       "         [-5.57869247e+02, -5.57867496e+02],\n",
       "         ...,\n",
       "         [            nan,             nan],\n",
       "         [            nan,             nan],\n",
       "         [            nan,             nan]],\n",
       "\n",
       "        [[-5.69810081e+02, -5.69808284e+02],\n",
       "         [-5.63205810e+02, -5.63204011e+02],\n",
       "         [-5.56640416e+02, -5.56638690e+02],\n",
       "         ...,\n",
       "...\n",
       "         ...,\n",
       "         [            nan,             nan],\n",
       "         [            nan,             nan],\n",
       "         [            nan,             nan]],\n",
       "\n",
       "        [[-6.53655526e-01, -6.88018523e-01],\n",
       "         [-6.49527560e-01, -6.83924940e-01],\n",
       "         [-6.45339813e-01, -6.76852419e-01],\n",
       "         ...,\n",
       "         [            nan,             nan],\n",
       "         [            nan,             nan],\n",
       "         [            nan,             nan]],\n",
       "\n",
       "        [[-6.52832830e-01, -6.87193231e-01],\n",
       "         [-6.48961268e-01, -6.83317841e-01],\n",
       "         [-6.44741565e-01, -6.76210511e-01],\n",
       "         ...,\n",
       "         [            nan,             nan],\n",
       "         [            nan,             nan],\n",
       "         [            nan,             nan]]]])</pre></div></li></ul></div></li><li class='xr-section-item'><input id='section-b3d5f821-28c2-4763-ba29-805cc693b85d' class='xr-section-summary-in' type='checkbox'  checked><label for='section-b3d5f821-28c2-4763-ba29-805cc693b85d' class='xr-section-summary' >Attributes: <span>(3)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><dl class='xr-attrs'><dt><span>long_name :</span></dt><dd>salinity</dd><dt><span>time :</span></dt><dd>ocean_time</dd><dt><span>field :</span></dt><dd>salinity, scalar, series</dd></dl></div></li></ul></div></div>"
      ],
      "text/plain": [
       "<xarray.DataArray 'salt' (ocean_time: 2, s_rho: 30, eta_rho: 191, xi_rho: 371)>\n",
       "[4251660 values with dtype=float32]\n",
       "Coordinates:\n",
       "    Cs_r        (s_rho) float64 -0.933 -0.8092 -0.6988 ... -0.0005206 -5.758e-05\n",
       "    lon_rho     (xi_rho, eta_rho) float64 -93.6 -93.6 -93.6 ... -88.86 -88.87\n",
       "    hc          float64 20.0\n",
       "    h           (xi_rho, eta_rho) float64 612.1 605.4 599.0 ... 5.0 5.0 5.0\n",
       "    lat_rho     (xi_rho, eta_rho) float64 27.45 27.46 27.48 ... 30.85 30.86\n",
       "    Vtransform  int32 2\n",
       "  * ocean_time  (ocean_time) datetime64[ns] 2001-08-01 2001-08-08\n",
       "  * s_rho       (s_rho) float64 -0.9833 -0.95 -0.9167 ... -0.05 -0.01667\n",
       "    z_rho       (s_rho, xi_rho, eta_rho, ocean_time) float64 -572.1 ... nan\n",
       "Dimensions without coordinates: eta_rho, xi_rho\n",
       "Attributes:\n",
       "    long_name:  salinity\n",
       "    time:       ocean_time\n",
       "    field:      salinity, scalar, series"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "if ds.Vtransform == 1:\n",
    "    Zo_rho = ds.hc * (ds.s_rho - ds.Cs_r) + ds.Cs_r * ds.h\n",
    "    z_rho = Zo_rho + ds.zeta * (1 + Zo_rho / ds.h)\n",
    "elif ds.Vtransform == 2:\n",
    "    Zo_rho = (ds.hc * ds.s_rho + ds.Cs_r * ds.h) / (ds.hc + ds.h)\n",
    "    z_rho = ds.zeta + (ds.zeta + ds.h) * Zo_rho\n",
    "\n",
    "ds.coords[\"z_rho\"] = z_rho.transpose()  # needing transpose seems to be an xarray bug\n",
    "ds.salt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "7b584e3a-6630-4f74-9f89-a95ba1b3af79",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "                <img id=screenshot_imjoy_window_1e695f50-9cc4-4664-8a6a-51c941b41d61 src=>\n",
       "                <script id=\"script_imjoy_window_1e695f50-9cc4-4664-8a6a-51c941b41d61\" type=\"text/javascript\">\n",
       "                    var container = document.getElementById(\"script_imjoy_window_1e695f50-9cc4-4664-8a6a-51c941b41d61\").parentNode;\n",
       "                    var image = document.getElementById(\"screenshot_imjoy_window_1e695f50-9cc4-4664-8a6a-51c941b41d61\");\n",
       "                    if (!image) {\n",
       "                        image = document.createElement(\"img\");\n",
       "                        image.id = \"screenshot_imjoy_window_1e695f50-9cc4-4664-8a6a-51c941b41d61\";\n",
       "                        container.appendChild(image);\n",
       "                    }\n",
       "                    image.src = \"\";\n",
       "                    var viewer = document.getElementById(\"imjoy_window_1e695f50-9cc4-4664-8a6a-51c941b41d61\");\n",
       "                    // Hide the static image if the Viewer is visible\n",
       "                    image.style.display = viewer ? \"none\" : \"block\";\n",
       "                </script>\n",
       "            "
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/javascript": [
       "window.connectPlugin && window.connectPlugin(\"fb48e912-9af8-4f29-8be7-0c810a80524b\")"
      ],
      "text/plain": [
       "<IPython.core.display.Javascript object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div id=\"8a637a9a-8dc9-4c56-ade0-4f60a1d70ff1\"></div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "<itkwidgets.viewer.Viewer at 0x7f36471e5f10>"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "view(\n",
    "    ds.salt.isel(ocean_time=0),\n",
    "    ui_collapsed=False,\n",
    "    cmap=\"Warm to Cool (Extended)\",\n",
    "    sample_distance=0,\n",
    "    color_range=[1, 36],\n",
    "    gradient_opacity=0.25,\n",
    "    gradient_opacity_scale=0.1\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "40201a35-4dc6-40de-8af4-c227d7afa9dd",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
